//
//  KColumnArrayCellView.m
//  MengLiao
//
//  Created by xiuxin on 2022/7/15.
//  Copyright © 2022 ZHBen. All rights reserved.
//

#import "KColumnCellView.h"
#import "KColumnInfo.h"
#import "KDDPosition.h"
#import "KMConfigStore.h"

@implementation KColumnCellView
KAddModelView(KColumnCellViewID)

+ (CGSize)sizeForSpec:(NSString *)spec model:(KColumnInfo *)model
{
    return model.itemSize;
}

+ (NSString *)specForModel:(KColumnInfo *)model
{
    return model.spec;
}

- (void)kmLoadModel:(KColumnInfo *)model position:(KDDPosition *)position
{
    UICollectionReusableView * cell = self.cell;
    if (cell != nil)
    {
        [model cellWillDisplay:cell contentView:self];
    }
}

- (void)ddWillDisplay:(KColumnInfo *)model position:(KDDPosition *)position
{
    UICollectionReusableView * cell = self.cell;
    if (cell != nil)
    {
        [model cellWillDisplay:cell contentView:self];
    }
}

- (void)ddEndDisplay:(KColumnInfo *)model position:(KDDPosition *)position
{
    if ([model isKindOfClass:[KColumnInfo class]])
    {
        [model cellDidEndDisplay:self.cell];
    }
}

- (UICollectionReusableView *)cell
{
    UIView * superView = self.superview;
    while (superView != nil && ![superView isKindOfClass:[UICollectionReusableView class]])
    {
        superView = superView.superview;
    }
    return (UICollectionReusableView *)superView;
}

@end
